<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<script src="http://code.jquery.com/jquery-1.7.js"></script>
<script type="text/javascript">
	function validation() {
		
		var frm = document.forms(0);
		if (frm.buy_points.value == "" || frm.purchase_price.value == "" ) {
			
			alert("포인트를 입력해주세요. 포인트가 없을경우 0을 입력해주세요");
			return false;
		}else if( isNaN(frm.buy_points.value) || isNaN(frm.purchase_price.value) ){
			alert("숫자만 입력해주세요");
			return false;
		}
		return true;
	}
	
	$(document).ready(function(){
		$('#buy_points').keyup(function(e){
			 var points = $('#buy_points').val();
			$('#purchase_price').val(points);
		}); 
	});
</script>
<h2 class="page_title"><strong>포인트 구매</strong></h2>

 <table>
	<tr height="40">
		<th>buy_points</th>
		<th>purchase_price</th>
		<th>pay_way</th>
		<th>buy_date</th>
	</tr>
	
	<s:iterator value="bp_list" status="stat">
	<tr height="40" class="align_c">
		<td><s:property value="buy_points"/></td>
		<td><s:property value="purchase_price"/></td>
		<td><s:property value="pay_way"/></td>
		<td><s:property value="buy_date"/></td>
	</tr>
	</s:iterator>
	<s:if test="bp_list.size()<=0">
	<tr height="40" class="align_c">
		<td colspan="11" >포인트 구매내역이 없습니다.</td>
	</tr>
	</s:if>
</table>
<br />
<p class="align_c"><s:property value="pagingHtml" escape="false"/></p>

<form id="buypoint" action="buyPoint.action" method="post" onsubmit="return validation();">
<fieldset>
<legend>포인트 구매</legend>
	<s:hidden name="id" value="%{session.session_id}" />
	<p class="mar_b_20">구매할 포인트를 입력해주세요. </p>
	<p><strong>BUY POINT</strong> : <input type="text" maxlength="7" name="buy_points" id="buy_points" /></p>
	<p><strong>PURCHASE PRICE</strong> : <input type="text" maxlength="7" name="purchase_price" id="purchase_price" readonly="readonly"/></p>
	<p class="mar_b_20">사용할 결제 방식을 선택해주세요. </p>
	<p>
		카드결제
		<input type="radio" name="pay_way" value="카드결제" checked="checked" />
		현금결제
		<input type="radio" name="pay_way" value="현금결제"/>
	</p>
	<p class="align_r"><input type="submit" value="BUY NOW" /></p>
</fieldset>
</form>
<s:if test="resultClass != null">
<h3 class="page_title"><strong>현제 포인트</strong></h3>
<table class="table_view">
	<colgroup>
		<col width="200px"/>
		<col />
	</colgroup>
	<tr>
		<th>point</th>
		<td><s:property value="resultClass.point"/></td>
	</tr>
</table>
</s:if>
<s:else>
	<p>포인트 내역이 없습니다</p>
</s:else>




